function formatJson(filterVal, list) {
  return list.map(v => filterVal.map(j => v[j]))
}

export function exportExcel(header, data, fileName) {
  const parseHeader = []
  const exportHeader = []
  Object.keys(header).forEach(item => {
    parseHeader.push(item)
    exportHeader.push(header[item])
  })
  import('@/vendor/Export2Excel').then(excel => {
    const list = formatJson(parseHeader, data)
    excel.export_json_to_excel({
      header: exportHeader,
      data: list,
      filename: fileName
    })
  })
}
